import 'package:flutter/material.dart';
import 'package:flutter_framework/views/test_json_ser/models/test_data_model.dart';
import 'package:flutter_framework/views/test_json_ser/provider/count_ctrl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class TestJsonSer extends StatefulWidget {
  const TestJsonSer({super.key});

  @override
  State<TestJsonSer> createState() => _TestJsonSerState();
}

class _TestJsonSerState extends State<TestJsonSer> {
  Person person = Person(
      firstName: '映培', lastName: "吴", dateOfBirth: DateTime(1997, 11, 02));
  StatusCodeEnhanced statusCode = StatusCodeEnhanced.movedPermanently;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("data"),
      ),
      body: Column(
        children: [
          Text(
              "测试文件${person.lastName},${person.dateOfBirth?.year},${statusCode.code}"),
          Consumer(builder: (ctx, WidgetRef ref, child) {
            return TextButton(
                onPressed: () {
                  ref.read(counterTestProvider.notifier).increment();
                },
                child: Text("加加 "));
          }),
          Consumer(builder: (ctx, WidgetRef ref, child) {
            var data = ref.watch(counterTestProvider);
            return Text("${data}");
          })
        ],
      ),
    );
  }
}
